//订单中心的数据
const state = {
    buyOrders: JSON.parse(localStorage.getItem('MYCENTERORDERS')) || []
}
const mutations = {
    updateOrder(state, newMyorder) {
        //把每一个提交支付过的订单存放在buyorder里面，然后方便在我的订单里面全部查看
        console.log('打印一下center仓库订单详情newMyorder：');
        console.log(newMyorder);
        // 判断 buyOrders 中是否已有与 newMyorder 相同的订单
        const exists = state.buyOrders.some(order => {
            // 假设根据 OrderID 判断是否相同
            return order.OrderID === newMyorder.OrderID;
        });

        if (!exists) {
            // 如果没有相同的订单，则添加到 buyOrders 中
            state.buyOrders.unshift(newMyorder);
            console.log('更新后的 buyOrders：', state.buyOrders);

            // 更新 localStorage
            localStorage.setItem('MYCENTERORDERS', JSON.stringify(state.buyOrders));
        } else {
            console.log('该订单已存在，未添加：', newMyorder);
        }
    }
}
const actions = {

}
const getters = {}
export default {
    namespaced: true,
    state, mutations,
    actions, getters
}